home *** CD-ROM | disk | FTP | other *** search
/ The Sunday Times: Parent Power / The Sunday Times - Parent Power.iso / pc / engine / search.swf / scripts / frame_2 / DoAction.as < prev   
Encoding:
Text File  |  2005-11-04  |  52.5 KB  |  1,578 lines

  1. function map_enable()
  2. {
  3.    map._visible = true;
  4. }
  5. function map_disable()
  6. {
  7.    map._visible = false;
  8. }
  9. function set_lea(lea)
  10. {
  11.    var _loc2_ = lea;
  12.    var _loc3_ = _g.gLEAArray.toString();
  13.    if(_loc3_.indexOf(_loc2_) >= 0)
  14.    {
  15.       _g.gLEA = _loc2_;
  16.       _g.gActiveSearch = "lea";
  17.       search_box.gotoAndPlay("lea");
  18.    }
  19.    var _loc1_ = 0;
  20.    while(_loc1_ < _g.gRegionArray.length)
  21.    {
  22.       if(_g.gRegionArray[_loc1_][0] == _loc2_)
  23.       {
  24.          _g.gRegion = _loc2_;
  25.          _g.gActiveSearch = "region";
  26.          search_box.gotoAndPlay("region");
  27.       }
  28.       _loc1_ = _loc1_ + 1;
  29.    }
  30. }
  31. function get_lea()
  32. {
  33.    return _g.gLEA;
  34. }
  35. function search_form_init()
  36. {
  37.    var _loc3_ = this;
  38.    _g.gActiveSearch = "";
  39.    if(search_int == undefined)
  40.    {
  41.       _g.gKeyListener.onKeyDown = function()
  42.       {
  43.          if(Key.getCode() == 13)
  44.          {
  45.             if(!_parent.search_in_progress && !_parent.dialogue_box)
  46.             {
  47.                if(_g.gActiveSearch == "name")
  48.                {
  49.                   if(search_int == undefined && _currentframe <= 40)
  50.                   {
  51.                      Key.removeListener(_g.gKeyListener);
  52.                      search_name();
  53.                   }
  54.                }
  55.                else if(_g.gActiveSearch == "postcode")
  56.                {
  57.                   if(search_int == undefined && _currentframe <= 40)
  58.                   {
  59.                      Key.removeListener(_g.gKeyListener);
  60.                      search_postcode();
  61.                   }
  62.                }
  63.                else if(_g.gActiveSearch == "posttown")
  64.                {
  65.                   if(search_int == undefined && _currentframe <= 40)
  66.                   {
  67.                      Key.removeListener(_g.gKeyListener);
  68.                      search_posttown();
  69.                   }
  70.                }
  71.                else if(search_int == undefined && _currentframe <= 40)
  72.                {
  73.                   Key.removeListener(_g.gKeyListener);
  74.                   search_name();
  75.                }
  76.             }
  77.          }
  78.       };
  79.       Key.addListener(_g.gKeyListener);
  80.    }
  81.    school_name.tabIndex = 1;
  82.    search_box.postcode.tabIndex = 2;
  83.    search_box.posttown.tabIndex = 2;
  84.    search_box.postcode.restrict = "A-Z 0-9";
  85.    search_box.postcode.onSetFocus = function()
  86.    {
  87.       _g.gActiveSearch = "postcode";
  88.       Key.addListener(_g.gKeyListener);
  89.    };
  90.    search_box.posttown.restrict = "A-Z \'";
  91.    search_box.posttown.onSetFocus = function()
  92.    {
  93.       _g.gActiveSearch = "posttown";
  94.       Key.addListener(_g.gKeyListener);
  95.    };
  96.    school_name.onSetFocus = function()
  97.    {
  98.       _g.gActiveSearch = "name";
  99.       Key.addListener(_g.gKeyListener);
  100.    };
  101.    school_name.restrict = "A-Z 0-9 \'";
  102.    _global.styles.TextInput.setStyle("borderStyle","none");
  103.    _global.styles.TextInput.setStyle("fontFamily","FrnkGothITC Bk BT");
  104.    _global.styles.TextInput.setStyle("color","0x3D2F25");
  105.    _global.styles.TextInput.setStyle("fontSize","14");
  106.    _global.styles.TextInput.setStyle("embedFonts","true");
  107.    _global.style.setStyle("themeColor","haloBlue");
  108.    search_box.postcode.setStyle("fontSize","15");
  109.    var _loc2_ = new Array(5,10,15,20,30,40,50);
  110.    search_box.searchLimit.removeAll();
  111.    var _loc1_ = 0;
  112.    while(_loc1_ < _loc2_.length)
  113.    {
  114.       search_box.searchLimit.addItem(_loc2_[_loc1_]);
  115.       _loc1_ = _loc1_ + 1;
  116.    }
  117.    search_box.searchLimit.setSelectedIndex(1);
  118.    _loc2_ = new Array("mixed and single sex","mixed","boys","girls");
  119.    search_box.gender.removeAll();
  120.    _loc1_ = 0;
  121.    while(_loc1_ < _loc2_.length)
  122.    {
  123.       search_box.gender.addItem(_loc2_[_loc1_]);
  124.       _loc1_ = _loc1_ + 1;
  125.    }
  126.    _loc2_ = new Array("all types of","all secondary","all primary","state secondary","state primary","independent secondary","independent preparatory");
  127.    search_box.typeOfSchool.removeAll();
  128.    _loc1_ = 0;
  129.    while(_loc1_ < _loc2_.length)
  130.    {
  131.       search_box.typeOfSchool.addItem(_loc2_[_loc1_]);
  132.       _loc1_ = _loc1_ + 1;
  133.    }
  134.    if(_g.gLastSearch.postcode.length > 1)
  135.    {
  136.       search_box.postcode.text = _g.gLastSearch.postcode;
  137.       search_box.searchLimit.text = _g.gLastSearch.searchLimit + " nearest schools";
  138.       search_box.typeOfSchool.text = _g.gLastSearch.typeOfSchool;
  139.       if(_g.gLastSearch.typeOfSchool == "all types of")
  140.       {
  141.          search_box.typeOfSchool.text += " school";
  142.       }
  143.       search_box.gender.text = _g.gLastSearch.gender;
  144.       _loc1_ = 0;
  145.       while(_loc1_ < 10)
  146.       {
  147.          if(search_box.searchLimit.getValue() == _g.gLastSearch.searchLimit)
  148.          {
  149.             break;
  150.          }
  151.          search_box.searchLimit.setSelectedIndex(_loc1_);
  152.          _loc1_ = _loc1_ + 1;
  153.       }
  154.       _loc1_ = 0;
  155.       while(_loc1_ < 10)
  156.       {
  157.          if(search_box.typeOfSchool.getValue() == _g.gLastSearch.typeOfSchool)
  158.          {
  159.             break;
  160.          }
  161.          search_box.typeOfSchool.setSelectedIndex(_loc1_);
  162.          _loc1_ = _loc1_ + 1;
  163.       }
  164.       _loc1_ = 0;
  165.       while(_loc1_ < 10)
  166.       {
  167.          if(search_box.gender.getValue() == _g.gLastSearch.gender)
  168.          {
  169.             break;
  170.          }
  171.          search_box.gender.setSelectedIndex(_loc1_);
  172.          _loc1_ = _loc1_ + 1;
  173.       }
  174.    }
  175.    else if(_g.gLastSearch.name.length > 1)
  176.    {
  177.       search_box.name_txt.text = _g.gLastSearch.name;
  178.    }
  179.    b_search.onRelease = function()
  180.    {
  181.       Key.removeListener(_g.gKeyListener);
  182.       if(_g.gActiveSearch == "lea")
  183.       {
  184.          search_lea();
  185.       }
  186.       else if(_g.gActiveSearch == "region")
  187.       {
  188.          _g.gRegion = search_box.region.getValue();
  189.          search_region();
  190.       }
  191.       else if(_g.gActiveSearch == "postcode")
  192.       {
  193.          search_postcode();
  194.       }
  195.       else if(_g.gActiveSearch == "posttown")
  196.       {
  197.          search_posttown();
  198.       }
  199.       else if(search_box.postcode.text.length > 1)
  200.       {
  201.          search_postcode();
  202.       }
  203.       else if(school_name.text.length > 1)
  204.       {
  205.          search_name();
  206.       }
  207.    };
  208.    b_search.onRollOver = function()
  209.    {
  210.       this.gotoAndStop(2);
  211.    };
  212.    b_search.onRollOut = b_search.onReleaseOutside = function()
  213.    {
  214.       this.gotoAndStop(1);
  215.    };
  216.    search_box.b_modify_search.onRelease = function()
  217.    {
  218.       if(_g.gNavActive == "shortlist")
  219.       {
  220.          _parent.nav_activate("search",this);
  221.       }
  222.       gotoAndPlay(1);
  223.    };
  224.    b_search_name.onRelease = function()
  225.    {
  226.       Key.removeListener(_g.gKeyListener);
  227.       search_name();
  228.    };
  229.    b_search_name.onRollOver = function()
  230.    {
  231.       this.gotoAndStop(2);
  232.    };
  233.    b_search_name.onRollOut = b_search_name.onReleaseOutside = function()
  234.    {
  235.       this.gotoAndStop(1);
  236.    };
  237.    b_indi_secondary.onRelease = function()
  238.    {
  239.       referrer = "search";
  240.       schools_search_preset(this._name);
  241.    };
  242.    b_indi_secondary_11_16.onRelease = function()
  243.    {
  244.       referrer = "search";
  245.       schools_search_preset(this._name);
  246.    };
  247.    b_indi_prep.onRelease = function()
  248.    {
  249.       referrer = "search";
  250.       schools_search_preset(this._name);
  251.    };
  252.    b_state_secondary.onRelease = function()
  253.    {
  254.       referrer = "search";
  255.       schools_search_preset(this._name);
  256.    };
  257.    b_state_secondary_11_16.onRelease = function()
  258.    {
  259.       referrer = "search";
  260.       schools_search_preset(this._name);
  261.    };
  262.    b_indi_secondary_scottish.onRelease = function()
  263.    {
  264.       referrer = "search";
  265.       schools_search_preset(this._name);
  266.    };
  267.    b_state_primary.onRelease = function()
  268.    {
  269.       referrer = "search";
  270.       schools_search_preset(this._name);
  271.    };
  272.    school_name.text = _g.gLastSearch.name.split(",").join(" ");
  273.    Selection.setFocus("school_name");
  274. }
  275. function string_remove_words(str, words)
  276. {
  277.    var _loc1_ = str;
  278.    _loc1_ = _loc1_.split(" ");
  279.    var _loc3_ = 0;
  280.    while(_loc3_ < _loc1_.length)
  281.    {
  282.       var _loc2_ = 0;
  283.       while(_loc2_ < words.length)
  284.       {
  285.          if(_loc1_[_loc3_] == words[_loc2_])
  286.          {
  287.             _loc1_.splice(_loc3_,1);
  288.          }
  289.          _loc2_ = _loc2_ + 1;
  290.       }
  291.       _loc3_ = _loc3_ + 1;
  292.    }
  293.    _loc1_ = _loc1_.toString();
  294.    _loc3_ = 0;
  295.    while(_loc3_ < _loc1_.length)
  296.    {
  297.       if(_loc1_.charAt(_loc3_) == ",")
  298.       {
  299.          _loc1_ = _loc1_.substring(0,_loc3_) + " " + _loc1_.substring(_loc3_ + 1,_loc1_.length);
  300.       }
  301.       _loc3_ = _loc3_ + 1;
  302.    }
  303.    return _loc1_;
  304. }
  305. function string_shorten_words(str, len)
  306. {
  307.    var _loc1_ = str;
  308.    var _loc3_ = len;
  309.    _loc1_ = _loc1_.split("\'").join("*");
  310.    _loc1_ = _loc1_.split(" ");
  311.    var _loc2_ = 0;
  312.    while(_loc2_ < _loc1_.length)
  313.    {
  314.       if(_loc1_[_loc2_].length > _loc3_)
  315.       {
  316.          _loc1_[_loc2_] = _loc1_[_loc2_].slice(0,_loc3_);
  317.       }
  318.       _loc2_ = _loc2_ + 1;
  319.    }
  320.    _loc1_ = _loc1_.toString();
  321.    _loc2_ = 0;
  322.    while(_loc2_ < _loc1_.length)
  323.    {
  324.       if(_loc1_.charAt(_loc2_) == ",")
  325.       {
  326.          _loc1_ = _loc1_.substring(0,_loc2_) + " " + _loc1_.substring(_loc2_ + 1,_loc1_.length);
  327.       }
  328.       _loc2_ = _loc2_ + 1;
  329.    }
  330.    return _loc1_;
  331. }
  332. function string_replace_words(str, word, newword)
  333. {
  334.    var _loc1_ = str;
  335.    _loc1_ = _loc1_.split(word).join(newword);
  336.    return _loc1_;
  337. }
  338. function string_normalise_results(txt)
  339. {
  340.    var _loc1_ = txt;
  341.    _loc1_ = _loc1_.toString();
  342.    _loc1_.split("%").join("");
  343.    if(_loc1_.indexOf(".") != -1)
  344.    {
  345.       if(_loc1_.charAt(2) == ".")
  346.       {
  347.          _loc1_ = _loc1_.substring(0,4);
  348.       }
  349.       else
  350.       {
  351.          _loc1_ = _loc1_.substring(0,3);
  352.       }
  353.       _loc1_ += "%";
  354.    }
  355.    else if(Math.round(_loc1_) > 0 && _loc1_.length >= 1)
  356.    {
  357.       _loc1_ += ".0%";
  358.    }
  359.    else
  360.    {
  361.       _loc1_ = "n/a";
  362.    }
  363.    if(_loc1_ == "0.0%" || _loc1_ == "0")
  364.    {
  365.       _loc1_ = "";
  366.    }
  367.    return _loc1_;
  368. }
  369. function ranking_normalise(rnk)
  370. {
  371.    var _loc1_ = rnk;
  372.    _loc1_ = _loc1_.toString();
  373.    var _loc2_ = 0;
  374.    if(_loc1_.indexOf(".1") > -1)
  375.    {
  376.       _loc2_ = _loc2_ + 1;
  377.    }
  378.    _loc1_ = Math.floor(_loc1_);
  379.    if(_loc1_ > 0)
  380.    {
  381.       _loc1_ = _loc1_.toString();
  382.       if(_loc2_)
  383.       {
  384.          _loc1_ += "=";
  385.       }
  386.    }
  387.    else
  388.    {
  389.       _loc1_ = _loc1_.toString();
  390.       _loc1_ = "";
  391.    }
  392.    return _loc1_;
  393. }
  394. function string_no_pct(txt)
  395. {
  396.    var _loc1_ = txt;
  397.    _loc1_ = _loc1_.toString();
  398.    _loc1_ = _loc1_.split(".")[0];
  399.    _loc1_ = _loc1_.split("%").join("");
  400.    if(_loc1_ == "0")
  401.    {
  402.       _loc1_ = "";
  403.    }
  404.    return _loc1_;
  405. }
  406. function currency_format(txt)
  407. {
  408.    var _loc1_ = txt;
  409.    _loc1_ = _loc1_.toString();
  410.    if(_loc1_.length > 3)
  411.    {
  412.       _loc1_ = _loc1_.substr(0,_loc1_.length - 3) + "," + _loc1_.substr(_loc1_.length - 3,_loc1_.length);
  413.    }
  414.    _loc1_ = "┬ú" + _loc1_;
  415.    return _loc1_;
  416. }
  417. function search_postcode()
  418. {
  419.    if(search_box.postcode.text.length <= 1)
  420.    {
  421.       Key.removeListener(_g.gKeyListener);
  422.       _parent.dialogue_add("Postcode too short!","Please enter a valid UK postcode including spaces, i.e. N1 1TY",275);
  423.    }
  424.    else
  425.    {
  426.       var _loc1_ = new Object();
  427.       _loc1_.sortBy = "posx,posy";
  428.       _g.gLastSearch.region = "";
  429.       _g.gLastSearch.lea = "";
  430.       _g.gLastSearch.name = "";
  431.       _loc1_.name = "";
  432.       schools_search(_loc1_);
  433.    }
  434. }
  435. function search_lea()
  436. {
  437.    var _loc3_ = new Object();
  438.    var _loc1_ = search_box.typeOfSchool.getValue();
  439.    if(_loc1_ == "all secondary")
  440.    {
  441.       _loc1_ = "State Secondary\' OR school_type = \'Independent Secondary";
  442.    }
  443.    else if(_loc1_ == "all primary")
  444.    {
  445.       _loc1_ = "State Primary\' OR school_type = \'Independent Preparatory and Junior";
  446.    }
  447.    else if(_loc1_ == "state secondary")
  448.    {
  449.       _loc1_ = "State Secondary";
  450.    }
  451.    else if(_loc1_ == "state primary")
  452.    {
  453.       _loc1_ = "State Primary";
  454.    }
  455.    else if(_loc1_ == "independent secondary")
  456.    {
  457.       _loc1_ = "Independent Secondary";
  458.    }
  459.    else if(_loc1_ == "independent preparatory")
  460.    {
  461.       _loc1_ = "Independent Preparatory and Junior";
  462.    }
  463.    var _loc2_ = search_box.gender.getValue();
  464.    if(_loc2_ == "mixed and single sex")
  465.    {
  466.       _loc2_ = "Boys\' OR entry_gender = \'Girls\'  OR entry_gender = \'Mixed";
  467.    }
  468.    else if(_loc2_ == "boys")
  469.    {
  470.       _loc2_ = "Boys";
  471.    }
  472.    else if(_loc2_ == "girls")
  473.    {
  474.       _loc2_ = "Girls";
  475.    }
  476.    else if(_loc2_ == "mixed")
  477.    {
  478.       _loc2_ = "Mixed";
  479.    }
  480.    if(_loc1_ == "all types of")
  481.    {
  482.       _loc3_.sql = "SELECT school_id,name,school_type,sub_type,st_ranking" + _g.thisYearShort + ",st_ranking" + _g.lastYearShort + ",town,entry_gender,posx,posy,unique_id FROM schools,results WHERE schools.school_id = results.school_id AND (entry_gender = \'" + _loc2_ + "\') AND (lea = \'" + _g.gLEA + "\') ORDER BY school_type";
  483.    }
  484.    else
  485.    {
  486.       _loc3_.sql = "SELECT school_id,name,school_type,sub_type,st_ranking" + _g.thisYearShort + ",st_ranking" + _g.lastYearShort + ",town,entry_gender,posx,posy,unique_id FROM schools,results WHERE schools.school_id = results.school_id AND (entry_gender = \'" + _loc2_ + "\') AND (lea = \'" + _g.gLEA + "\') AND (school_type = \'" + _loc1_ + "\') ORDER BY school_type";
  487.    }
  488.    _loc3_.searchLimit = 500;
  489.    _g.gLastSearch.lea = _g.gLEA;
  490.    schools_search(_loc3_);
  491. }
  492. function search_region()
  493. {
  494.    var search = new Object();
  495.    var _loc3_ = undefined;
  496.    var _loc2_ = 0;
  497.    while(_loc2_ < _g.gRegionArray.length)
  498.    {
  499.       if(_g.gRegionArray[_loc2_][0] == _g.gRegion)
  500.       {
  501.          var _loc1_ = 1;
  502.          while(_loc1_ < _g.gRegionArray[_loc2_].length)
  503.          {
  504.             _loc3_ += "(lea = \'" + _g.gRegionArray[_loc2_][_loc1_] + "\')";
  505.             if(_loc1_ < _g.gRegionArray[_loc2_].length - 1)
  506.             {
  507.                _loc3_ += " OR ";
  508.             }
  509.             _loc1_ = _loc1_ + 1;
  510.          }
  511.       }
  512.       _loc2_ = _loc2_ + 1;
  513.    }
  514.    if(_g.gRegion == "Scotland")
  515.    {
  516.       _loc3_ += " OR school_id = \'SIS006\'";
  517.    }
  518.    var typeOfSchool = search_box.typeOfSchool.getValue();
  519.    if(typeOfSchool == "all secondary")
  520.    {
  521.       typeOfSchool = "State Secondary\' OR school_type = \'Independent Secondary";
  522.    }
  523.    else if(typeOfSchool == "all primary")
  524.    {
  525.       typeOfSchool = "State Primary\' OR school_type = \'Independent Preparatory and Junior";
  526.    }
  527.    else if(typeOfSchool == "state secondary")
  528.    {
  529.       typeOfSchool = "State Secondary";
  530.    }
  531.    else if(typeOfSchool == "state primary")
  532.    {
  533.       typeOfSchool = "State Primary";
  534.    }
  535.    else if(typeOfSchool == "independent secondary")
  536.    {
  537.       typeOfSchool = "Independent Secondary";
  538.    }
  539.    else if(typeOfSchool == "independent preparatory")
  540.    {
  541.       typeOfSchool = "Independent Preparatory and Junior";
  542.    }
  543.    var gender = search_box.gender.getValue();
  544.    if(gender == "mixed and single sex")
  545.    {
  546.       gender = "Boys\' OR entry_gender = \'Girls\' OR entry_gender = \'Mixed";
  547.    }
  548.    else if(gender == "boys")
  549.    {
  550.       gender = "Boys";
  551.    }
  552.    else if(gender == "girls")
  553.    {
  554.       gender = "Girls";
  555.    }
  556.    else if(gender == "mixed")
  557.    {
  558.       gender = "Mixed";
  559.    }
  560.    if(typeOfSchool == "all types of")
  561.    {
  562.       search.sql = "SELECT school_id,name,school_type,sub_type,st_ranking" + _g.thisYearShort + ",st_ranking" + _g.lastYearShort + ",town,entry_gender,posx,posy,unique_id FROM schools,results WHERE schools.school_id = results.school_id AND (entry_gender = \'" + gender + "\') AND (" + _loc3_ + ") ORDER BY school_type";
  563.    }
  564.    else
  565.    {
  566.       search.sql = "SELECT school_id,name,school_type,sub_type,st_ranking" + _g.thisYearShort + ",st_ranking" + _g.lastYearShort + ",town,entry_gender,posx,posy,unique_id FROM schools,results WHERE schools.school_id = results.school_id AND (entry_gender = \'" + gender + "\') AND (" + _loc3_ + ") AND (school_type = \'" + typeOfSchool + "\') ORDER BY school_type";
  567.    }
  568.    search.searchLimit = 500;
  569.    _g.gLastSearch.region = _g.gRegion;
  570.    schools_search(search);
  571. }
  572. function search_name()
  573. {
  574.    _g.gLastSearch.postcode = "";
  575.    var search = new Object();
  576.    search.postcode = 0;
  577.    search.typeOfSchool = 0;
  578.    search.gender = 0;
  579.    _g.gLastSearch.region = "";
  580.    _g.gLastSearch.lea = "";
  581.    search.searchLimit = 250;
  582.    search.sortBy = sortBy;
  583.    search.sortDir = 0;
  584.    if(school_name.text.length <= 2)
  585.    {
  586.       _parent.dialogue_add("Name too short!","Please search for a minimum of 3 characters",275);
  587.    }
  588.    else
  589.    {
  590.       var school_name = school_name.text.split("\n").toString();
  591.       _g.gLastSearch.name = school_name;
  592.       school_name = string_remove_words(school_name,["THE","OF","AND","OR","PRIMARY","SECONDARY","JUNIOR","PREPARATORY "]);
  593.       school_name = string_replace_words(school_name,"SAINT ","ST ");
  594.       school_name = string_replace_words(school_name,"CHURCH OF ENGLAND","C OF E");
  595.       school_name = string_replace_words(school_name,"ROMAN CATHOLIC","RC");
  596.       school_name = string_replace_words(school_name,"\'"," ");
  597.       school_name = string_shorten_words(school_name,6);
  598.       school_name = school_name.split(" ");
  599.       var _loc2_ = undefined;
  600.       var _loc1_ = 0;
  601.       while(_loc1_ < school_name.length)
  602.       {
  603.          var _loc3_ = school_name[_loc1_].toUpperCase();
  604.          if(_loc3_ != "MARY")
  605.          {
  606.             _loc2_ += "name LIKE \'" + _loc3_ + "\' no_case ";
  607.             if(_loc1_ < school_name.length - 1)
  608.             {
  609.                _loc2_ += " AND ";
  610.             }
  611.          }
  612.          else
  613.          {
  614.             _loc2_ += "(name LIKE \' MARY\' no_case OR name LIKE \'\\AMARY\' no_case)";
  615.             if(_loc1_ < school_name.length - 1)
  616.             {
  617.                _loc2_ += " AND ";
  618.             }
  619.          }
  620.          _loc1_ = _loc1_ + 1;
  621.       }
  622.       search.sql = "SELECT school_id,name,school_type,sub_type,st_ranking" + _g.thisYearShort + ",st_ranking" + _g.lastYearShort + ",town,entry_gender,posx,posy,unique_id FROM schools,results WHERE schools.school_id = results.school_id AND " + _loc2_ + " ORDER BY school_type";
  623.       search.name = school_name;
  624.       schools_search(search);
  625.    }
  626. }
  627. function search_posttown()
  628. {
  629.    _g.gLastSearch.postcode = "";
  630.    var search = new Object();
  631.    search.postcode = 0;
  632.    search.typeOfSchool = 0;
  633.    search.gender = 0;
  634.    _g.gLastSearch.region = "";
  635.    _g.gLastSearch.lea = "";
  636.    search.searchLimit = 250;
  637.    search.sortBy = sortBy;
  638.    search.sortDir = 0;
  639.    if(search_box.posttown.text.length <= 2)
  640.    {
  641.       _parent.dialogue_add("Town name too short!","Please search for a minimum of 3 characters",275);
  642.    }
  643.    else
  644.    {
  645.       var _loc2_ = search_box.posttown.text.split("\n").toString();
  646.       _loc2_ = string_remove_words(_loc2_,["THE","OF","AND"]);
  647.       _loc2_ = string_replace_words(_loc2_,"\'"," ");
  648.       _loc2_ = string_shorten_words(_loc2_,6);
  649.       _loc2_ = _loc2_.split(" ");
  650.       var search_criteria;
  651.       var _loc1_ = 0;
  652.       while(_loc1_ < _loc2_.length)
  653.       {
  654.          var _loc3_ = _loc2_[_loc1_].toUpperCase();
  655.          search_criteria += "posttown LIKE \'" + _loc3_ + "\' no_case";
  656.          if(_loc1_ < _loc2_.length - 1)
  657.          {
  658.             search_criteria += " AND ";
  659.          }
  660.          _loc1_ = _loc1_ + 1;
  661.       }
  662.       var typeOfSchool = search_box.typeOfSchool.getValue();
  663.       if(typeOfSchool == "all secondary")
  664.       {
  665.          typeOfSchool = "State Secondary\' OR school_type = \'Independent Secondary";
  666.       }
  667.       else if(typeOfSchool == "all primary")
  668.       {
  669.          typeOfSchool = "State Primary\' OR school_type = \'Independent Preparatory and Junior";
  670.       }
  671.       else if(typeOfSchool == "state secondary")
  672.       {
  673.          typeOfSchool = "State Secondary";
  674.       }
  675.       else if(typeOfSchool == "state primary")
  676.       {
  677.          typeOfSchool = "State Primary";
  678.       }
  679.       else if(typeOfSchool == "independent secondary")
  680.       {
  681.          typeOfSchool = "Independent Secondary";
  682.       }
  683.       else if(typeOfSchool == "independent preparatory")
  684.       {
  685.          typeOfSchool = "Independent Preparatory and Junior";
  686.       }
  687.       var gender = search_box.gender.getValue();
  688.       if(gender == "mixed and single sex")
  689.       {
  690.          gender = "Boys\' OR entry_gender = \'Girls\' OR entry_gender = \'Mixed";
  691.       }
  692.       else if(gender == "boys")
  693.       {
  694.          gender = "Boys";
  695.       }
  696.       else if(gender == "girls")
  697.       {
  698.          gender = "Girls";
  699.       }
  700.       else if(gender == "mixed")
  701.       {
  702.          gender = "Mixed";
  703.       }
  704.       if(typeOfSchool == "all types of")
  705.       {
  706.          search.sql = "SELECT school_id,name,school_type,sub_type,st_ranking" + _g.thisYearShort + ",st_ranking" + _g.lastYearShort + ",town,entry_gender,posx,posy,unique_id FROM schools,results WHERE schools.school_id = results.school_id AND (entry_gender = \'" + gender + "\') AND " + search_criteria + " ORDER BY school_type";
  707.       }
  708.       else
  709.       {
  710.          search.sql = "SELECT school_id,name,school_type,sub_type,st_ranking" + _g.thisYearShort + ",st_ranking" + _g.lastYearShort + ",town,entry_gender,posx,posy,unique_id FROM schools,results WHERE schools.school_id = results.school_id AND (entry_gender = \'" + gender + "\') AND " + search_criteria + " AND (school_type = \'" + typeOfSchool + "\') ORDER BY school_type";
  711.       }
  712.       search.name = posttown;
  713.       schools_search(search);
  714.    }
  715. }
  716. function schools_search(search, sort)
  717. {
  718.    var _loc1_ = search;
  719.    trace("~~~~~~~~~~~~~~~~ SEARCH ~~~~~~~~~~~~~~~~~~~");
  720.    _g.gGlobalSearch = false;
  721.    _parent.search_in_progress_view();
  722.    oCurrentSearch = _loc1_;
  723.    if(search_int == undefined)
  724.    {
  725.       clearInterval(search_int);
  726.       Key.removeListener(_g.gKeyListener);
  727.       school_summary_remove();
  728.       if(!sort)
  729.       {
  730.          if(!sort.sql)
  731.          {
  732.             if(!_loc1_.postcode)
  733.             {
  734.                if(search_box.postcode.text.length > 1)
  735.                {
  736.                   _loc1_.postcode = search_box.postcode.text;
  737.                }
  738.             }
  739.             if(!_loc1_.searchLimit)
  740.             {
  741.                _loc1_.searchLimit = search_box.searchLimit.getValue();
  742.             }
  743.             if(!_loc1_.typeOfSchool)
  744.             {
  745.                if(search_box.typeOfSchool.getValue().length > 1)
  746.                {
  747.                   _loc1_.typeOfSchool = search_box.typeOfSchool.getValue();
  748.                }
  749.             }
  750.             if(!_loc1_.gender)
  751.             {
  752.                if(search_box.gender.getValue().length > 1)
  753.                {
  754.                   _loc1_.gender = search_box.gender.getValue();
  755.                }
  756.             }
  757.             if(_loc1_.sortBy.length < 1)
  758.             {
  759.                _loc1_.sortBy = 0;
  760.             }
  761.             if(!_loc1_.title)
  762.             {
  763.                _loc1_.title = 0;
  764.             }
  765.          }
  766.       }
  767.       _loc1_.schoolsArray = new Object();
  768.       if(_loc1_.profile != 1)
  769.       {
  770.          _g.gLastSearch = _loc1_;
  771.          _g.gLastSearch.region = _g.gRegion;
  772.          _g.gLastSearch.lea = _g.gLEA;
  773.          _g.gLastSearch.sql = _loc1_.sql;
  774.       }
  775.       search_int = setInterval(search_delay,750,_loc1_);
  776.    }
  777. }
  778. function search_delay(search)
  779. {
  780.    clearInterval(search_int);
  781.    clearInterval(search_int);
  782.    clearInterval(search_int);
  783.    search_int = undefined;
  784.    _g.gActiveSearch = "";
  785.    search_submit(search);
  786. }
  787. function search_submit(search)
  788. {
  789.    var _loc1_ = search;
  790.    clearInterval(search_int);
  791.    getURL("lingo: search_init(\"" + _loc1_.postcode + "\",\"" + _loc1_.posttown + "\",\"" + _loc1_.typeOfSchool + "\",\"" + _loc1_.gender + "\"," + _loc1_.searchLimit + ",\"" + _loc1_.sortBy + "\",\"" + _g.gSort_Ascending + "\",\"" + _loc1_.name + "\",\"" + _loc1_.sql + "\",\"" + _loc1_.id + "\",\"" + _loc1_.profile + "\",\"" + _loc1_.criteria_list + "\")","");
  792. }
  793. function schools_search_revise(pos)
  794. {
  795.    _g.gLastSearch.sql = _g.gLastSearch.sql_source;
  796.    schools_search(_g.gLastSearch);
  797. }
  798. function school_summary_create(schoolsArray, searchLimit, id, history, profile, name, criteria_list, dest_sql_query, source_sql_query, schoolOfTheYearFound)
  799. {
  800.    _g.gSchool_array = [];
  801.    schoolsArray = schoolsArray.split("[").join("").split("]").join("");
  802.    schoolsArray = schoolsArray.split("::");
  803.    var tmpArray = new Array();
  804.    var criteria_listArray;
  805.    if(criteria_list.length > 1)
  806.    {
  807.       criteria_listArray = criteria_list.split(",");
  808.    }
  809.    else
  810.    {
  811.       criteria_listArray = _g.gSearch_Results_Criteria_list;
  812.    }
  813.    if(profile != 1)
  814.    {
  815.       var _loc2_ = 0;
  816.       while(_loc2_ <= searchLimit)
  817.       {
  818.          school_new_array = schoolsArray[_loc2_].split("|");
  819.          if(!school_new_array)
  820.          {
  821.             break;
  822.          }
  823.          school = new Object();
  824.          var _loc3_ = criteria_listArray.length;
  825.          var _loc1_ = 0;
  826.          while(_loc1_ < _loc3_)
  827.          {
  828.             school[String(criteria_listArray[_loc1_])] = school_new_array[_loc1_];
  829.             _loc1_ = _loc1_ + 1;
  830.          }
  831.          tmpArray.push(school);
  832.          _loc2_ = _loc2_ + 1;
  833.       }
  834.    }
  835.    else
  836.    {
  837.       trace("profile or league table");
  838.       _loc2_ = 0;
  839.       while(_loc2_ <= searchLimit)
  840.       {
  841.          school_new_array = schoolsArray[_loc2_].split("|");
  842.          if(!school_new_array)
  843.          {
  844.             break;
  845.          }
  846.          school = new Object();
  847.          _loc3_ = _g.gCriteria_list.length;
  848.          _loc1_ = 0;
  849.          while(_loc1_ < _loc3_)
  850.          {
  851.             school[String(_g.gCriteria_list[_loc1_][0])] = school_new_array[_loc1_];
  852.             _loc1_ = _loc1_ + 1;
  853.          }
  854.          tmpArray.push(school);
  855.          _loc2_ = _loc2_ + 1;
  856.       }
  857.    }
  858.    _g.gSchool_array = tmpArray;
  859.    school_summary_remove();
  860.    _parent.search_in_progress_remove();
  861.    if(profile != 1)
  862.    {
  863.       _g.gLastSearch.schoolsArray = tmpArray;
  864.       if(dest_sql_query.length > 0)
  865.       {
  866.          _g.gLastSearch.sql = dest_sql_query;
  867.       }
  868.       if(source_sql_query.length > 0)
  869.       {
  870.          _g.gLastSearch.sql_source = source_sql_query;
  871.       }
  872.       school_summary_view(id,0,criteria_listArray,schoolOfTheYearFound);
  873.    }
  874.    else
  875.    {
  876.       school_view(_g.gSchool_array[0][0]);
  877.    }
  878. }
  879. function school_summary_remove()
  880. {
  881.    content.removeMovieClip();
  882.    search_results_mask.removeMovieClip();
  883. }
  884. function school_summary_sort(sortBy)
  885. {
  886.    if(_g.gSort_Ascending == 1)
  887.    {
  888.       _g.gSort_Ascending = 0;
  889.    }
  890.    else
  891.    {
  892.       _g.gSort_Ascending = 1;
  893.    }
  894.    var _loc3_ = undefined;
  895.    if(_g.gLastSearch.sql.indexOf(" DESC") > 1)
  896.    {
  897.       _loc3_ = " ASC";
  898.    }
  899.    else if(_g.gLastSearch.sql.indexOf(" ASC") > 1)
  900.    {
  901.       _loc3_ = " DESC";
  902.    }
  903.    else
  904.    {
  905.       _loc3_ = " DESC";
  906.    }
  907.    if(sortBy != _g.gLastSearch.sortBy)
  908.    {
  909.       _g.gSort_Ascending = 1;
  910.       _loc3_ = " ASC";
  911.    }
  912.    var _loc2_ = "";
  913.    var _loc1_ = 0;
  914.    while(_loc1_ < _g.gLastSearch.schoolsArray.length)
  915.    {
  916.       _loc2_ += "\'" + _g.gLastSearch.schoolsArray[_loc1_].unique_id + "\'";
  917.       if(_loc1_ < _g.gLastSearch.schoolsArray.length - 1)
  918.       {
  919.          _loc2_ += " OR school_id = ";
  920.       }
  921.       _loc1_ = _loc1_ + 1;
  922.    }
  923.    var newSQL;
  924.    newSQL = String(_g.gLastSearch.sql).split("results.school_id AND")[0];
  925.    newSQL += " results.school_id AND school_id = " + _loc2_ + " ";
  926.    var sql = newSQL.split("ORDER BY ")[0];
  927.    _g.gLastSearch.sql = sql + "ORDER BY " + sortBy;
  928.    _g.gLastSearch.sql += _loc3_;
  929.    _g.gLastSearch.sortBy = sortBy;
  930.    schools_search(_g.gLastSearch,1);
  931.    trace("sort here:" + _g.gLastSearch.sql);
  932. }
  933. function school_summary_view(id, profile, criteria_listArray, schoolOfTheYearFound)
  934. {
  935.    school_info.removeMovieClip();
  936.    print_template.removeMovieClip();
  937.    trace("school_summary_view");
  938.    if(id.length < 10)
  939.    {
  940.       if(_g.gNavActive == "shortlist")
  941.       {
  942.          gotoAndStop("search_results_shortlist");
  943.          play();
  944.       }
  945.       else if(_g.gLastSearch.postcode.length > 1)
  946.       {
  947.          gotoAndStop("search_results_postcode");
  948.          play();
  949.       }
  950.       else
  951.       {
  952.          gotoAndStop("search_results_name");
  953.          play();
  954.       }
  955.    }
  956.    else
  957.    {
  958.       gotoAndStop("school_table");
  959.       play();
  960.       table_id.htmlText = id;
  961.    }
  962.    var d = _g.gClipLevel++;
  963.    createEmptyMovieClip("content",d);
  964.    y = 135;
  965.    x = 210;
  966.    var changeColour = 1;
  967.    y = scrollbar._y;
  968.    var i = 0;
  969.    while(i < _g.gSchool_array.length)
  970.    {
  971.       if(oCurrentSearch.templateId != null)
  972.       {
  973.          var clip = "table_item" + gClipLevel;
  974.          x = 30;
  975.          if(i == 0)
  976.          {
  977.             y = 229;
  978.          }
  979.          content.attachMovie("template" + oCurrentSearch.templateId,clip,_g.gClipLevel++,{_x:x,_y:y});
  980.       }
  981.       else
  982.       {
  983.          var clip = "school_summary" + gClipLevel;
  984.          content.attachMovie("school_summary",clip,_g.gClipLevel++,{_x:x,_y:y});
  985.       }
  986.       clip = eval("content." + clip);
  987.       if(changeColour < 0)
  988.       {
  989.          clip.bg.gotoAndPlay(2);
  990.          clip.school_shortlist_indicator.bg.gotoAndPlay(2);
  991.       }
  992.       var len = criteria_listArray.length;
  993.       var j = 0;
  994.       while(j < len)
  995.       {
  996.          clip[criteria_listArray[j]] = _g.gSchool_array[i][criteria_listArray[j]];
  997.          j++;
  998.       }
  999.       var st_ranking_this_year = _g.gSchool_array[i]["st_ranking" + _g.thisYearShort];
  1000.       if(schoolOfTheYearFound > 0)
  1001.       {
  1002.          var isSchoolOfYear = 0;
  1003.          var k = 0;
  1004.          while(k < 6)
  1005.          {
  1006.             var school_id = _g.gSchool_array[i].unique_id;
  1007.             if(_g.gSchoolsOfTheYear[k] == school_id && school_id != "")
  1008.             {
  1009.                clip.gotoAndStop(2);
  1010.                schoolOfTheYearFound--;
  1011.                break;
  1012.             }
  1013.             k++;
  1014.          }
  1015.       }
  1016.       if(st_ranking_this_year > 0 && st_ranking_this_year != 999)
  1017.       {
  1018.          clip.times_ranking_txt.text = ranking_normalise(st_ranking_this_year);
  1019.       }
  1020.       else
  1021.       {
  1022.          clip.times_ranking_txt.text = "";
  1023.          clip.times_ranking_arrow.unloadMovie();
  1024.       }
  1025.       var st_ranking_last_year = _g.gSchool_array[i]["st_ranking" + _g.lastYearShort];
  1026.       clip.times_ranking_previous_txt.text = ranking_normalise(st_ranking_last_year);
  1027.       var entrygender = _g.gSchool_array[i].entry_gender;
  1028.       entrygender = entrygender.toLowerCase();
  1029.       if(entrygender.indexOf("boys") != -1)
  1030.       {
  1031.          clip.gender_indicator.gotoAndPlay("boys");
  1032.       }
  1033.       else if(entrygender.indexOf("girls") != -1)
  1034.       {
  1035.          clip.gender_indicator.gotoAndPlay("girls");
  1036.       }
  1037.       else
  1038.       {
  1039.          clip.gender_indicator.gotoAndPlay("mixed");
  1040.       }
  1041.       var school_type = _g.gSchool_array[i].school_type;
  1042.       var sub_type = _g.gSchool_array[i].sub_type;
  1043.       var num_pupils_6form = Math.round(_g.gSchool_array[i].num_pupils_6form);
  1044.       clip.school_type_icon.gotoAndPlay(school_type);
  1045.       if(sub_type.indexOf("Scottish") > -1)
  1046.       {
  1047.          clip.school_type_icon.txt.text = "SCO";
  1048.       }
  1049.       else if(sub_type.indexOf("11-16") > -1)
  1050.       {
  1051.          if(num_pupils_6form >= 1 && num_pupils_6form < 10)
  1052.          {
  1053.             clip.school_type_icon.txt.text = "SmS";
  1054.          }
  1055.          else
  1056.          {
  1057.             clip.school_type_icon.txt.text = "NS";
  1058.          }
  1059.       }
  1060.       else if(sub_type.indexOf("Small") > -1)
  1061.       {
  1062.          clip.school_type_icon.txt.text = "Sm";
  1063.       }
  1064.       clip.gcse_a_star_a = string_normalise_results(_g.gSchool_array[i].gcse_a_star_a);
  1065.       clip.a_level_a_b = string_normalise_results(_g.gSchool_array[i].a_level_a_b);
  1066.       clip.a_level_rank = ranking_normalise(_g.gSchool_array[i].a_level_rank);
  1067.       clip.a_level_rank_2003 = ranking_normalise(eval("_g.gSchool_array[i][\'a_level_rank_" + _g.lastYear + "\']"));
  1068.       clip.gcse_rank = ranking_normalise(_g.gSchool_array[i].gcse_rank);
  1069.       clip.gcse_rank_2003 = ranking_normalise(eval("_g.gSchool_array[i][\'gcse_rank_" + _g.lastYear + "\']"));
  1070.       clip.scot_2004_higher_rank = ranking_normalise(_g.gSchool_array[i]["scot_" + _g.thisYear + "_higher_rank"]);
  1071.       clip.scot_2004_standard_int2_rank = ranking_normalise(_g.gSchool_array[i]["scot_" + _g.thisYear + "_standard_int2_rank"]);
  1072.       clip.scotstate_2004_standard_int2_rank = ranking_normalise(_g.gSchool_array[i]["scotstate_" + _g.lastYear + "_standard_int2_rank"]);
  1073.       clip.scotstate_2004_higher_rank = ranking_normalise(_g.gSchool_array[i]["scotstate_" + _g.lastYear + "_higher_rank"]);
  1074.       clip.scot_standard_int2_avg = string_normalise_results(_g.gSchool_array[i].scot_standard_int2_avg);
  1075.       clip.scot_standard_avg = clip.scot_standard_avg.split("%").join("");
  1076.       clip.scot_standard_avg = _g.gSchool_array[i].scot_standard_avg.split(".")[0];
  1077.       var pct = _g.gSchool_array[i].scot_standard_avg.split(".")[1].charAt(0);
  1078.       if(pct < 1)
  1079.       {
  1080.          pct = 0;
  1081.       }
  1082.       pct = "." + pct;
  1083.       clip.scot_standard_avg += pct + "%";
  1084.       clip.scot_higher_avg = clip.scot_higher_avg.split("%").join("");
  1085.       clip.scot_higher_avg = _g.gSchool_array[i].scot_higher_avg.split(".")[0];
  1086.       var pct = _g.gSchool_array[i].scot_higher_avg.split(".")[1].charAt(0);
  1087.       if(pct < 1)
  1088.       {
  1089.          pct = 0;
  1090.       }
  1091.       pct = "." + pct;
  1092.       clip.scot_higher_avg += pct + "%";
  1093.       clip.scot_2004_higher_a_b = string_normalise_results(_g.gSchool_array[i]["scot_" + _g.thisYear + "_higher_a_b"]);
  1094.       clip.scot_2004_higher_standard_2_1a = string_normalise_results(_g.gSchool_array[i]["scot_" + _g.thisYear + "_standard_1_int2_a"]);
  1095.       var sixth_form_2003_avg_points = _g.gSchool_array[i]["sixth_form_" + _g.lastYear + "_avg_points"].split(".")[0];
  1096.       var pct = _g.gSchool_array[i]["sixth_form_" + _g.lastYear + "_avg_points"].split(".")[1].charAt(0);
  1097.       if(pct < 1)
  1098.       {
  1099.          pct = 0;
  1100.       }
  1101.       pct = "." + pct;
  1102.       sixth_form_2003_avg_points += pct;
  1103.       clip.sixth_form_2004_avg_points = sixth_form_2003_avg_points;
  1104.       var shortlist = _g.gShortlist.schools.toString();
  1105.       if(_g.gShortlist.schools.length > 0 && _g.gShortlist.schools.toString().indexOf(_g.gSchool_array[i].unique_id) >= 0)
  1106.       {
  1107.          clip.school_shortlist_indicator.gotoAndPlay("active");
  1108.       }
  1109.       st_rankingThisYear = _g.gSchool_array[i]["st_ranking" + _g.thisYearShort];
  1110.       st_rankingLastYear = _g.gSchool_array[i]["st_ranking" + _g.lastYearShort];
  1111.       st_rankingThisYear = Number(st_rankingThisYear);
  1112.       st_rankingLastYear = Number(st_rankingLastYear);
  1113.       if(st_rankingThisYear <= 0)
  1114.       {
  1115.          clip.times_ranking_arrow.unloadMovie();
  1116.       }
  1117.       else if(st_rankingThisYear > st_rankingLastYear)
  1118.       {
  1119.          if(st_rankingLastYear > 0)
  1120.          {
  1121.             clip.times_ranking_arrow.gotoAndPlay("down");
  1122.          }
  1123.          else
  1124.          {
  1125.             clip.times_ranking_arrow.unloadMovie();
  1126.          }
  1127.       }
  1128.       else if(st_rankingThisYear == st_rankingLastYear)
  1129.       {
  1130.          clip.times_ranking_arrow.gotoAndPlay("same");
  1131.       }
  1132.       else if(st_rankingThisYear < st_rankingLastYear)
  1133.       {
  1134.          clip.times_ranking_arrow.gotoAndPlay("up");
  1135.       }
  1136.       changeColour *= -1;
  1137.       y += 19;
  1138.       i++;
  1139.    }
  1140.    if(id.length < 10)
  1141.    {
  1142.       attachMovie("search_results_mask","search_results_mask",_g.gClipLevel++,{_x:210,_y:179});
  1143.    }
  1144.    else if(oCurrentSearch.templateId != null)
  1145.    {
  1146.       attachMovie("search_results_mask","search_results_mask",_g.gClipLevel++,{_x:30,_y:229});
  1147.       search_results_mask._height = 323;
  1148.       search_results_mask._width = 728;
  1149.       mcTableHeaders.gotoAndStop(oCurrentSearch.templateId + 1);
  1150.    }
  1151.    else
  1152.    {
  1153.       attachMovie("search_results_mask","search_results_mask",_g.gClipLevel++,{_x:210,_y:219});
  1154.       search_results_mask._height = 323;
  1155.    }
  1156.    content.setMask(search_results_mask);
  1157.    scrollbar_init(content);
  1158. }
  1159. function school_get_id(id, pos)
  1160. {
  1161.    var _loc3_ = 0;
  1162.    var _loc1_ = 0;
  1163.    while(_loc1_ < _g.gLastSearch.schoolsArray.length)
  1164.    {
  1165.       if(_g.gLastSearch.schoolsArray[_loc1_].unique_id == id)
  1166.       {
  1167.          var _loc2_ = _loc1_ + pos;
  1168.          if(_loc2_ < 0)
  1169.          {
  1170.             _loc2_ = _g.gLastSearch.schoolsArray.length - 1;
  1171.          }
  1172.          else if(_loc2_ >= _g.gLastSearch.schoolsArray.length)
  1173.          {
  1174.             _loc2_ = 0;
  1175.          }
  1176.          _loc3_ = _g.gLastSearch.schoolsArray[_loc2_].unique_id;
  1177.          _loc1_ = _g.gLastSearch.schoolsArray.length + 1;
  1178.       }
  1179.       _loc1_ = _loc1_ + 1;
  1180.    }
  1181.    return _loc3_;
  1182. }
  1183. function school_get_info(id)
  1184. {
  1185.    var school_id = 0;
  1186.    info = new Object();
  1187.    var _loc3_ = 0;
  1188.    while(_loc3_ < _g.gSchool_array.length)
  1189.    {
  1190.       if(_g.gSchool_array[_loc3_].unique_id == id)
  1191.       {
  1192.          school_id = _loc3_;
  1193.       }
  1194.       _loc3_ = _loc3_ + 1;
  1195.    }
  1196.    var len = _g.gCriteria_list.length;
  1197.    var _loc2_ = 0;
  1198.    while(_loc2_ < len)
  1199.    {
  1200.       attrib_len = _g.gCriteria_list[_loc2_].length;
  1201.       var _loc1_ = 0;
  1202.       while(_loc1_ < attrib_len)
  1203.       {
  1204.          info[_g.gCriteria_list[_loc2_][_loc1_]] = _g.gSchool_array[school_id][_g.gCriteria_list[_loc2_][_loc1_]];
  1205.          _loc1_ = _loc1_ + 1;
  1206.       }
  1207.       _loc2_ = _loc2_ + 1;
  1208.    }
  1209.    return info;
  1210. }
  1211. function school_view(newid, pos)
  1212. {
  1213.    trace("school_view - id is: " + newid);
  1214.    trace("gClipLevel: " + gClipLevel);
  1215.    var _loc3_ = school_get_id(id,pos);
  1216.    school_info.removeMovieClip();
  1217.    print_template.removeMovieClip();
  1218.    updateAfterEvent();
  1219.    var _loc1_ = school_get_info(_loc3_);
  1220.    content._visible = false;
  1221.    var _loc2_ = undefined;
  1222.    if(_loc1_.school_type == "Independent Secondary")
  1223.    {
  1224.       if(_loc1_.category == "Enhanced")
  1225.       {
  1226.          if(_loc1_.sub_type == "Scottish independent secondary")
  1227.          {
  1228.             _loc2_ = "info_independent_secondary_profiled_scottish";
  1229.          }
  1230.          else if(_loc1_.sub_type == "Scottish independent secondary (A-levels)")
  1231.          {
  1232.             _loc2_ = "info_independent_secondary_profiled_scottish_a_levels";
  1233.          }
  1234.          else if(_loc1_.sub_type == "Independent secondary (small sixth form)")
  1235.          {
  1236.             _loc2_ = "info_independent_secondary_non_profiled_11_16";
  1237.          }
  1238.          else
  1239.          {
  1240.             _loc2_ = "info_independent_secondary_profiled";
  1241.          }
  1242.       }
  1243.       else if(_loc1_.category != "Enhanced")
  1244.       {
  1245.          if(_loc1_.sub_type == "Independent secondary (11-16)")
  1246.          {
  1247.             _loc2_ = "info_independent_secondary_non_profiled_11_16";
  1248.          }
  1249.          else if(_loc1_.sub_type == "Scottish independent secondary")
  1250.          {
  1251.             _loc2_ = "info_independent_secondary_non_profiled_scottish";
  1252.          }
  1253.          else if(_loc1_.sub_type == "Scottish independent secondary (A-levels)")
  1254.          {
  1255.             _loc2_ = "info_independent_secondary_non_profiled_scottish_a_levels";
  1256.          }
  1257.          else if(_loc1_.sub_type == "Independent secondary (small sixth form)")
  1258.          {
  1259.             _loc2_ = "info_independent_secondary_non_profiled_11_16";
  1260.          }
  1261.          else
  1262.          {
  1263.             _loc2_ = "info_independent_secondary_non_profiled";
  1264.          }
  1265.       }
  1266.    }
  1267.    else if(_loc1_.school_type == "State Secondary")
  1268.    {
  1269.       if(_loc1_.category == "Enhanced")
  1270.       {
  1271.          if(_loc1_.sub_type == "State secondary (11-16)")
  1272.          {
  1273.             _loc2_ = "info_state_secondary_profiled_11_16";
  1274.          }
  1275.          else if(_loc1_.sub_type == "Scottish state secondary")
  1276.          {
  1277.             _loc2_ = "info_state_secondary_profiled_scottish";
  1278.          }
  1279.          else if(_loc1_.sub_type == "Sixth form college")
  1280.          {
  1281.             _loc2_ = "info_state_secondary_profiled_sixth_form";
  1282.          }
  1283.          else
  1284.          {
  1285.             _loc2_ = "info_state_secondary_profiled";
  1286.          }
  1287.       }
  1288.       else if(_loc1_.category != "Enhanced")
  1289.       {
  1290.          if(_loc1_.sub_type == "State secondary (11-16)")
  1291.          {
  1292.             _loc2_ = "info_state_secondary_non_profiled_11_16";
  1293.          }
  1294.          else if(_loc1_.sub_type == "Scottish state secondary")
  1295.          {
  1296.             _loc2_ = "info_state_secondary_non_profiled_scottish";
  1297.          }
  1298.          else if(_loc1_.sub_type == "Sixth form college")
  1299.          {
  1300.             _loc2_ = "info_state_secondary_non_profiled_sixth_form";
  1301.          }
  1302.          else
  1303.          {
  1304.             _loc2_ = "info_state_secondary_non_profiled";
  1305.          }
  1306.       }
  1307.    }
  1308.    else if(_loc1_.school_type == "Independent Preparatory and Junior")
  1309.    {
  1310.       if(_loc1_.category == "Enhanced")
  1311.       {
  1312.          if(_loc1_.sub_type == "Independent preparatory and junior (SATs)")
  1313.          {
  1314.             _loc2_ = "info_independent_preparatory_profiled_sat";
  1315.          }
  1316.          else
  1317.          {
  1318.             _loc2_ = "info_independent_preparatory_profiled_non_sat";
  1319.          }
  1320.       }
  1321.       else if(_loc1_.category != "Enhanced")
  1322.       {
  1323.          if(_loc1_.sub_type == "Independent preparatory and junior (SATs)")
  1324.          {
  1325.             _loc2_ = "info_independent_preparatory_non_profiled_sat";
  1326.          }
  1327.          else
  1328.          {
  1329.             _loc2_ = "info_independent_preparatory_non_profiled_non_sat";
  1330.          }
  1331.       }
  1332.    }
  1333.    else if(_loc1_.school_type == "State Primary")
  1334.    {
  1335.       if(_loc1_.category == "Enhanced")
  1336.       {
  1337.          if(_loc1_.sub_type == "Small state primary")
  1338.          {
  1339.             _loc2_ = "info_small_state_primary_profiled";
  1340.          }
  1341.          else if(_loc1_.sub_type == "Northern Ireland state primary" || _loc1_.sub_type == "Welsh state primary" || _loc1_.sub_type == "Scottish state primary")
  1342.          {
  1343.             _loc2_ = "info_state_primary_scot_welsh_ni_profiled";
  1344.          }
  1345.          else
  1346.          {
  1347.             _loc2_ = "info_state_primary_profiled";
  1348.          }
  1349.       }
  1350.       else if(_loc1_.category != "Enhanced")
  1351.       {
  1352.          if(_loc1_.sub_type == "Small state primary")
  1353.          {
  1354.             _loc2_ = "info_small_state_primary_non_profiled";
  1355.          }
  1356.          else
  1357.          {
  1358.             _loc2_ = "info_state_primary_non_profiled";
  1359.          }
  1360.       }
  1361.    }
  1362.    attachMovie(_loc2_,"school_info",_g.gClipLevel++,{_x:15,_y:2045});
  1363.    trace("mcTemplateID:" + _loc2_);
  1364.    school_info.printTemplateID = _loc2_.split("info_").join("print_");
  1365.    gotoAndStop("school_info");
  1366.    play();
  1367.    _loc1_;
  1368. }
  1369. function info_tabs_init(tabID, col)
  1370. {
  1371.    with(school_info)
  1372.    {
  1373.       var tabArray = new Array("b_info","b_profile","b_details");
  1374.       var i = 0;
  1375.       while(i < tabArray.length)
  1376.       {
  1377.          var tab = tabArray[i].split("_")[1];
  1378.          if(tab != tabID)
  1379.          {
  1380.             _parent._parent.colour_change(eval(tabArray[i]).bg,col);
  1381.          }
  1382.          else
  1383.          {
  1384.             var myColorTransform = {ra:100,rb:0,ga:100,gb:0,ba:100,bb:0,aa:100,ab:0};
  1385.             _parent._parent.colour_change(eval(tabArray[i]).bg,myColorTransform);
  1386.          }
  1387.          i++;
  1388.       }
  1389.       b_info.onRelease = b_profile.onRelease = b_details.onRelease = function()
  1390.       {
  1391.          var tabArray = new Array("b_info","b_profile","b_details");
  1392.          var tabID = this._name;
  1393.          var i = 0;
  1394.          while(i < tabArray.length)
  1395.          {
  1396.             trace("!!!!");
  1397.             if(tabArray[i] != tabID)
  1398.             {
  1399.                _parent._parent.colour_change(eval(tabArray[i]).bg,col);
  1400.             }
  1401.             else
  1402.             {
  1403.                var myColorTransform = {ra:100,rb:0,ga:100,gb:0,ba:100,bb:0,aa:100,ab:0};
  1404.                _parent._parent.colour_change(eval(tabID).bg,myColorTransform);
  1405.             }
  1406.             i++;
  1407.          }
  1408.          gotoAndPlay(this._name.split("_")[1]);
  1409.       };
  1410.    }
  1411. }
  1412. function print_school(templateID)
  1413. {
  1414.    trace("print using: " + templateID);
  1415.    attachMovie(templateID,"print_template",_g.gClipLevel++,{_x:250,_y:1500});
  1416.    info_init(print_template);
  1417.    results_panel_init(print_template);
  1418.    print_int = setInterval(print_school_send_to_printer,500);
  1419. }
  1420. function print_school_send_to_printer()
  1421. {
  1422.    clearInterval(print_int);
  1423.    getURL("printasbitmap:",print_template);
  1424. }
  1425. function setTablePage1ButtonHandlers()
  1426. {
  1427.    var _loc1_ = this;
  1428.    b_indi_secondary.onRelease = function()
  1429.    {
  1430.       referrer = "tables";
  1431.       schools_search_preset(this._name);
  1432.    };
  1433.    b_indi_secondary_11_16.onRelease = function()
  1434.    {
  1435.       referrer = "tables";
  1436.       schools_search_preset(this._name);
  1437.    };
  1438.    b_indi_secondary_scottish_en.onRelease = function()
  1439.    {
  1440.       referrer = "tables";
  1441.       schools_search_preset(this._name);
  1442.    };
  1443.    b_indi_secondary_scottish_sc.onRelease = function()
  1444.    {
  1445.       referrer = "tables";
  1446.       schools_search_preset(this._name);
  1447.    };
  1448.    b_indi_prep.onRelease = function()
  1449.    {
  1450.       referrer = "tables";
  1451.       schools_search_preset(this._name);
  1452.    };
  1453.    b_indi_prep_a_z.onRelease = function()
  1454.    {
  1455.       referrer = "tables";
  1456.       schools_search_preset(this._name);
  1457.    };
  1458.    b_state_secondary.onRelease = function()
  1459.    {
  1460.       referrer = "tables";
  1461.       schools_search_preset(this._name);
  1462.    };
  1463.    b_state_secondary_11_16.onRelease = function()
  1464.    {
  1465.       referrer = "tables";
  1466.       schools_search_preset(this._name);
  1467.    };
  1468.    b_state_secondary_sixth.onRelease = function()
  1469.    {
  1470.       referrer = "tables";
  1471.       schools_search_preset(this._name);
  1472.    };
  1473.    b_state_secondary_scotland.onRelease = function()
  1474.    {
  1475.       referrer = "tables";
  1476.       schools_search_preset(this._name);
  1477.    };
  1478.    b_state_primary.onRelease = function()
  1479.    {
  1480.       referrer = "tables";
  1481.       schools_search_preset(this._name);
  1482.    };
  1483.    b_state_primary_small.onRelease = function()
  1484.    {
  1485.       referrer = "tables";
  1486.       schools_search_preset(this._name);
  1487.    };
  1488.    b_state_primary_scot.onRelease = function()
  1489.    {
  1490.       referrer = "tables";
  1491.       schools_search_preset(this._name);
  1492.    };
  1493.    b_state_primary_welsh.onRelease = function()
  1494.    {
  1495.       referrer = "tables";
  1496.       schools_search_preset(this._name);
  1497.    };
  1498.    b_state_primary_ni.onRelease = function()
  1499.    {
  1500.       referrer = "tables";
  1501.       schools_search_preset(this._name);
  1502.    };
  1503. }
  1504. _g = _global;
  1505. _g.thisYear = String(_g.cdYearFull);
  1506. _g.thisYearShort = String(_g.cdYearFull).substring(2,4);
  1507. _g.lastYear = String(_g.cdYearFull - 1);
  1508. _g.lastYearShort = String(_g.cdYearFull - 1).substring(2,4);
  1509. _g.gKeyListener = new Object();
  1510. _g.gSchool_array = new Array();
  1511. if(!_g.gLastSearch)
  1512. {
  1513.    _g.gLastSearch = new Object();
  1514. }
  1515. _g.gActiveSearch = "";
  1516. _g.gLEA;
  1517. _g.gRegion;
  1518. _g.gRegionArray = new Array(["Please select..."]);
  1519. _g.gRegionArray.push(["London","Corporation of London","Barking and Dagenham","Barnet","Bexley","Brent","Bromley","Camden","City of London","Croydon","Ealing","Enfield","Greenwich","Hackney","Hammersmith and Fulham","Haringey","Harrow","Havering","Hillingdon","Hounslow","Islington","Kensington and Chelsea","Kingston upon Thames","Lambeth","Lewisham","Merton","Newham","Redbridge","Richmond upon Thames","Southwark","Sutton","Tower Hamlets","Waltham Forest","Wandsworth","Westminster"]);
  1520. _g.gRegionArray.push(["South East","Essex","Hertfordshire","Buckinghamshire","Milton Keynes","Oxfordshire","West Berkshire","West Sussex","East Sussex","Kent","Hampshire","Southampton","Portsmouth","Brighton and Hove","Isle of Wight","Reading","Wokingham","Bracknell Forest","Windsor and Maidenhead","Slough","Luton","Thurrock","Medway","Southend on Sea","Surrey"]);
  1521. _g.gRegionArray.push(["South West","Guernsey","Jersey","Cornwall","Isles of Scilly","Torbay","Plymouth","Devon","Somerset","Bristol","South Gloucestershire","Bath and North East Somerset","North Somerset","Wiltshire","Swindon","Dorset","Poole","Bournemouth","Gloucestershire"]);
  1522. _g.gRegionArray.push(["Midlands","Birmingham","Dudley","Walsall","Sandwell","Solihull","Coventry","Wolverhampton","Warwickshire","Northamptonshire","Leicestershire","Leicester","Nottinghamshire","Nottingham","Derbyshire","Derby","Staffordshire","Stoke-on-Trent","Shropshire","Telford and Wrekin","Worcestershire","Herefordshire"]);
  1523. _g.gRegionArray.push(["North West","Isle of Man","Wigan","Lancashire","Cheshire","Wirral","Blackpool","Blackburn with Darwen","Rochdale","Bury","Bolton","Sefton","Liverpool","Knowsley","St Helens","Salford","Manchester","Oldham","Tameside","Trafford","Warrington","Halton","Stockport"]);
  1524. _g.gRegionArray.push(["North","Northumberland","North Tyneside","Newcastle upon Tyne","Gateshead","South Tyneside","Sunderland","Durham","Cumbria","North Yorkshire","Middlesbrough","Stockton-on-Tees","Darlington","Redcar and Cleveland","Hartlepool","East Riding of Yorkshire","York","Leeds","Bradford","Wakefield","Calderdale","Kirklees","Barnsley","Doncaster","Rotherham","Sheffield","Kingston upon Hull"]);
  1525. _g.gRegionArray.push(["Eastern","North Lincolnshire","North East Lincolnshire","Lincolnshire","Rutland","Peterborough","Cambridgeshire","Norfolk","Suffolk","Bedfordshire"]);
  1526. _g.gRegionArray.push(["Scotland","Scotland"]);
  1527. _g.gRegionArray.push(["Wales","Welsh","Wales","Isle of Angelsey","Gwynedd","Conwy","Denbighshire","Flintshire","Wrexham","Powys","Ceredigion","Carmarthenshire","Pembrokeshire","Swansea","Neath Port Talbot","Bridgend","Rhondda, Cynon, Taff","Vale of Glamorgan","Merthyr Tydfil","Caerphilly","Cardiff","Newport","Blaenau Gwent","Torfaen","Monmouthshire"]);
  1528. _g.gRegionArray.push(["Northern Ireland","Belfast","Northern Ireland","Belfast library board","South Eastern library board","Southern library board","Western library board","North Eastern library board"]);
  1529. _g.gLEAArray = new Array("Please select...","Barking and Dagenham","Barnet","Barnsley","Bath and North East Somerset","Bedfordshire","Bexley","Birmingham","Blackburn with Darwen","Blackpool","Bolton","Bournemouth","Bracknell Forest","Bradford","Brent","Brighton and Hove","Bristol","Bromley","Buckinghamshire","Bury","Calderdale","Cambridgeshire","Camden","Cheshire","City of London","Cornwall","Coventry","Croydon","Cumbria","Darlington","Derby","Derbyshire","Devon","Doncaster","Dorset","Dudley","Durham","Ealing","East Riding of Yorkshire","East Sussex","Enfield","Essex","Gateshead","Gloucestershire","Greenwich","Hackney","Halton","Hammersmith and Fulham","Hampshire","Haringey","Harrow","Hartlepool","Havering","Herefordshire","Hertfordshire","Hillingdon","Hounslow","Isle of Wight","Isles of Scilly","Islington","Kensington and Chelsea","Kent","Kingston upon Hull","Kingston-upon-Thames","Kirklees","Knowsley","Lambeth","Lancashire","Leeds","Leicester","Leicestershire","Lewisham","Lincolnshire","Liverpool","Luton","Manchester","Medway","Merton","Middlesbrough","Milton Keynes","Newcastle upon Tyne","Newham","Norfolk","North East Lincolnshire","North Lincolnshire","North Somerset","North Tyneside","North Yorkshire","Northamptonshire","Northumberland","Nottingham","Nottinghamshire","Oldham","Oxfordshire","Peterborough","Plymouth","Poole","Portsmouth","Reading","Redbridge","Redcar and Cleveland","Richmond-upon-Thames","Rochdale","Rotherham","Rutland","Salford","Sandwell","Sefton","Sheffield","Shropshire","Slough","Solihull","Somerset","South Gloucestershire","South Tyneside","Southampton","Southend on Sea","Southwark","St Helens","Staffordshire","Stockport","Stockton-on-Tees","Stoke-on-Trent","Suffolk","Sunderland","Surrey","Sutton","Swindon","Tameside","Telford and Wrekin","Thurrock","Torbay","Tower Hamlets","Trafford","Wakefield","Walsall","Waltham Forest","Wandsworth","Warrington","Warwickshire","West Berkshire","West Sussex","Westminster","Wigan","Wiltshire","Windsor and Maidenhead","Wirral","Wokingham","Wolverhampton","Worcestershire","York");
  1530. _g.gSchoolsOfTheYear = new Array("199172","IS249","212756","216949","199428","IS010");
  1531. oCurrentSearch = new Object();
  1532. setTablePage1ButtonHandlers();
  1533. if(map.getBytesLoaded() < 50)
  1534. {
  1535.    map.loadMovie("map.swf");
  1536. }
  1537. map_enable();
  1538. school_summary_remove();
  1539. if(_g.gNavActive == "shortlist")
  1540. {
  1541.    Key.removeListener(_g.gKeyListener);
  1542.    content.gotoAndPlay("search_results_shortlist");
  1543.    var search = new Object();
  1544.    search.searchLimit = 100;
  1545.    var schools_in_shortlist = "";
  1546.    if(_g.gShortlist.schools.length >= 1)
  1547.    {
  1548.       var i = 0;
  1549.       while(i < _g.gShortlist.schools.length)
  1550.       {
  1551.          schools_in_shortlist += "\'" + _g.gShortlist.schools[i] + "\'";
  1552.          if(i < _g.gShortlist.schools.length - 1)
  1553.          {
  1554.             schools_in_shortlist += " OR school_id = ";
  1555.          }
  1556.          i++;
  1557.       }
  1558.       search.sql = "SELECT school_id,name,school_type,sub_type,st_ranking" + _g.thisYearShort + ",st_ranking" + _g.lastYearShort + ",town,entry_gender,posx,posy,unique_id FROM schools,results WHERE schools.school_id = results.school_id AND school_id = " + schools_in_shortlist + " ORDER BY st_ranking" + _g.thisYearShort + ",st_ranking" + _g.lastYearShort + " DESC";
  1559.       schools_search(search);
  1560.    }
  1561.    else
  1562.    {
  1563.       Key.removeListener(_g.gKeyListener);
  1564.       if(search_int == undefined)
  1565.       {
  1566.          var id = new Object();
  1567.          id.title = "You have no schools within your shortlist";
  1568.          id.content = "To shortlist a school, click it\'s save icon";
  1569.          _parent.help_view(id,clip);
  1570.       }
  1571.    }
  1572. }
  1573. else if(_g.gGlobalSearch)
  1574. {
  1575.    schools_search(_g.gGlobalSearch);
  1576. }
  1577. _g.gSort_Ascending = 0;
  1578.